package game.players.cpu.opponent;

import com.uqbar.vainilla.appearances.Animation;
import com.uqbar.vainilla.appearances.Sprite;

import game.players.SoccerPlayer;
import game.players.states.ShootingPlayer;
import game.soccerField.Arc;

public class ShootingCPUOppPlayer extends ShootingPlayer {

	public ShootingCPUOppPlayer(final SoccerPlayer player) {
		super(player);
		
		player.setAppearance(new Animation(0.3,
				Sprite.fromImage("/images/goal3_tiro3.png").crop(0, 2, 57, 65).scale(1.5).flipHorizontally(),
				Sprite.fromImage("/images/goal3_tiro3.png").crop(83, 0, 37, 65).scale(1.5).flipHorizontally(),
				Sprite.fromImage("/images/goal3_tiro3.png").crop(143, 0, 51, 65).scale(1.5).flipHorizontally()
				));
	}
	
	@Override
	protected void executeShoot() {
		Arc arc = this.getPlayer().getRivalArc();
		double i = arc.getX() - this.getPlayer().getX();
		double j = arc.getY() + this.getPlayer().getRivalArc().getAppearance().getHeight() / 2 - this.getPlayer().getY();
		
		this.getSoccerBall().roll(SPEED, i, j);
		this.getPlayer().setState(new WithoutBallStationaryCPUOpp(this.getPlayer()));
	}

	@Override
	public void loseTheBall() {
		this.getTimer().cancel();
		this.getPlayer().setState(new BeatenCPUOppPlayer(this.getPlayer(), this.isRight()));
	}
	
	@Override
	public boolean isRight() {
		return false;
	}

}
